package com.xw.p03_SingletonPattern;

/**
 * @author XW
 * @data 2023/12/4 14:58
 * @description 大臣每天上朝
 */
public class Minister {

    public static void main(String[] args) {
        work1();
    }

    public static void work1(){
        for (int i = 0; i < 10; i++) {
            new Thread(() -> {
                for (int j = 0; j < 10; j++) {
                    HungryEmperor instance = HungryEmperor.getHungryEmperor();
                    System.out.print(Thread.currentThread() + "****");
                    instance.emperorInfo();
                }
            }).start();
        }
    }

    public static void work(){
        for (int i = 0; i < 10; i++) {
            new Thread(() -> {
                for (int j = 0; j < 10; j++) {
                    LazyEmperor instance = LazyEmperor.getInstance();
                    System.out.print(Thread.currentThread() + "****");
                    instance.emperorInfo();
                }
            }).start();
        }
    }
}
